<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class HomeUserBindEmailValidata extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
     public function rules()
     {
         return [
             'phone'     => ['required', 'regex:/^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/u'],
             'bindemail' => 'required|email|unique:shop_home_users,email',
             'emailcode' => 'required|max:6|min:6',
         ];
     }

     public function messages()
     {
         return [
             'emailcode.max'      => '验证码不能大于六位',
             'emailcode.min'      => '验证码不能小于六位',
             'emailcode.required' => '验证码不能为空',
             'phone.required'     => '手机号码不能为空',
             'phone.regex'        => '手机号格式不正确',
             'bindemail.required' => '邮箱不能为空',
             'bindemail.email'    => '邮箱格式不正确',
             'bindemail.unique'   => '该邮箱已被注册',

         ];
     }
}
